package com.tanhua.model.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class PageResult implements Serializable {
    private Long counts = 0L; //总记录数
    private Integer pageSize = 10; //页大小
    private Long pages = 0L; //总页数
    private Integer page = 1; //当前页码
    private List<?> items = Collections.emptyList(); //列表

    public PageResult(Integer page,Integer pageSize,
                      long counts,List list) {
        this.page = page;
        this.pageSize = pageSize;
        this.items = list;
        this.counts = counts;
        this.pages = counts % pageSize == 0 ? counts / pageSize : counts / pageSize + 1;
    }
}
